from photo_services import *

import sys
try:
    import gdata.service
except ImportError:
    sys.exit('GData Python Client Library is not installed: http://code.google.com/p/gdata-python-client/')
    raise 

class PicasaPhotoService(AbstractPhotoService):
    def __init__(self, username, password):
        self.username = username
        self.service = self._login(password)
    
    def _login(self, password):
        """
        Performs user authentication and returns service object if successful
        """
        gds = gdata.service.GDataService()
        gds.email = self.username
        gds.password = password
        gds.service = 'lh2'
        try:
            gds.ProgrammaticLogin()
        except gdata.service.Error, e:
            sys.exit("Can't log on to Picasa: %s" % e)
        return gds